<?php
	include 'include/functions.php';
	$commonscores = array(3,6,7,9,10,13,14,17,21,24,27,28,31,34,35,42);
	$sizeIn = sizeof($commonscores)-1;
	$winscore = 0;
	$losescore = 0;

	# Generate Two Random Scores from the List above until the winscore is greater than the losescore
	do
	{
		$losescore = $commonscores[rand(0,$sizeIn)];
		$winscore = $commonscores[rand(0,$sizeIn)];
	} while ($losescore >= $winscore);
	
	//Connect To Database
	dbConnect();
	
	$Weeknum = getWeek("NFL");
	
	//check to make sure $Weeknum > 1 AND $Weeknum < 21
	$Weeknum = checkWeekBounds($Weeknum);
	
	# Get Array of Home Teams & Array of Away Teams for this week.
	$query="SELECT * FROM NFLSchedule Where (WEEK=".$Weeknum.") ORDER BY GameNum";
	$doQuery=mysql_query($query);
	$numrows=mysql_num_rows($doQuery);
	$num = 1;
	if($numrows > 0)
	{
		while($results=mysql_fetch_array($doQuery))
		{
			//Fill Arrays With Data
			$homeTeams[$num]=$results['Home'];
			$awayTeams[$num]=$results['Away'];
			$num++;
		}
	}
	
	# Get Random Monkey's Picks for this Week, store in randompicks[] array.
	$query2="SELECT * FROM NFLPicks WHERE Week = $Weeknum AND UserID = 7";
	$doQuery2=mysql_query($query2);
	$numrows2=mysql_num_rows($doQuery2);
	$num2 = 1;
	if($numrows2 > 0)
	{
		$results=mysql_fetch_array($doQuery2);
		while($num2 <= $num)
		{	//Fill Arrays With Data
			$randompicks[$num2]=$results["Game".$num2];
			$num2++;
		}
	}
	
	# Grab a Game number at random.
	$game = rand(1,$num);
	while (($awayTeams[$game] == "") || (($homeTeams[$game] == "")))
	{
		$game = rand(1,$num);
	}
	
	# Display Random Monkey's Lock Pick of the Week.
	echo "<body bgcolor=\"#DDDDDD\">";
	echo "<table style=\"width: 170px;\">";
	echo "<tr><td colspan=\"2\" align=\"center\"><b>Random Monkey's<br/>Lock of the Week:<br/>Week ".$Weeknum."<br/></b></td></tr>";
	echo "<tr><td width=\"50\"><img src=\"/images/icons/0.gif\" alt=\"Random Monkey\" /></td><td align=\"center\">";
	if($awayTeams[$game] == $randompicks[$game])	# If Monkey picked the away team, give them winning score.
		echo "<span style=\"color: #ff0000\">".$awayTeams[$game]." ".$winscore."</span>";
	else											# Else give the away team the losing score.
		echo $awayTeams[$game]." ".$losescore;
	
	echo "<br/> @ <br/>";
	
	if($homeTeams[$game] == $randompicks[$game])	# If Monkey picked the home team, give them winning score.
		echo "<span style=\"color: #ff0000\">".$homeTeams[$game]." ".$winscore."</span>";
	else											# Else give the home team the losing score.
		echo $homeTeams[$game]." ".$losescore;

	echo "</td></tr>";
	echo "</table>";
	#echo "<div style=\"width: 170px; text-align: center;\">";
	#echo "<b style=\"margin-bottom: 0px;\">Random Monkey's<br/>Lock of the Week: Week ".$Weeknum."<br/></b>";
	
	
	#echo "<br/><img src=\"/images/icons/0.gif\" alt=\"Random Monkey\" /></div>";
?>